{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}
{block name="content"}
<div class="t-art" style="margin-bottom:10px;">
    <a class="btn btn-blue" href="/AcpContract/add_edit_park_contract"><i class="gicon-plus white"></i>添加园区合同</a>
    <a class="btn btn-blue" href="/AcpContract/add_edit_zhongchuang_contract"><i class="gicon-plus white"></i>添加众创空间合同</a>
</div>
<div class="tablesWrap">
    <div class="tables-searchbox">
        <form method="post">
            <span class="tbs-txt">企业名称：</span>
            <input type="text" name="company_name" value="{$company_name}">

            <span class="tbs-txt">联系人：</span>
              <input type="text" class="mini" name="linkman" value="{$linkman}">

            <!-- <span class="tbs-txt">添加时间：</span>
             <input type="text" autocomplete="off" class="Wdate" name="start_date" value="{$start_date|date_format:'%Y-%m-%d'}"  onclick="WdatePicker()">
             <span class="tbs-txt">至</span>
             <input type="text" autocomplete="off" class="Wdate" name="end_date" value="{$end_date|date_format:'%Y-%m-%d'}"  onclick="WdatePicker()">-->
            <button type="submit" class="btn"><i class="gicon-search"></i>搜索</button>
        </form>
    </div>
<!-- end tables-searchbox -->  
<table class="wxtables">  
    <colgroup>  
    <col width="6%">
    <col width="10%">
    <col width="10%">
    <col width="10%">
    <col width="10%">
    <col width="10%">
    <col width="10%">
    <col width="10%">
    <col width="10%">
    </colgroup>
    <thead>
        <tr>
            <td>选择</td>
            <td>企业名称</td>
            <td>联系人</td>
            <td>联系方式</td>
            <td>开始时间</td>
            <td>结束时间</td>
            <td>租凭总金额</td>
            <td>孵化器类型</td>
            <td>操作</td>
        </tr>  
    </thead>  
	{foreach from=$contract_list item=this}
    <tbody class="combo-tbody">  
        <tr>
            <td><input type="checkbox" class="checkbox" value="{$item.item_id}" name="checkIds[]"></td>
			<td>{$this.company_name}</td>
			<td>{$this.linkman}</td>
			<td>{$this.link_way}</td>
			<td>{$this.start_time|date_format:"%Y-%m-%d %H:%M:%S"}</td>
			<td>{$this.end_time|date_format:"%Y-%m-%d %H:%M:%S"}</td>
			<td>{$this.lease_total_money}</td>
			<td>{if $this.contract_type == 1}园区{else}众创空间{/if}</td>
            <td>
                {if !$this.service_label}
				<a href="/AcpContract/add_edit_{if $this.contract_type == 1}park_contract{else}zhongchuang_contract{/if}/contract_id/{$this.contract_id}" class="btn" title="修改">修改</a>
                <a href="/AcpContract/contract_detail/contract_id/{$this.contract_id}" class="btn" title="详情">详情</a>
                <a href="javascript:;" class="btn" title="删除" onclick="delete_service_type({$this.type_id})">删除</a>
                {/if}
            </td>  
        </tr>
    </tbody>
	{foreachelse}   
    <tbody>    
		<tr>
			<td colspan="7">
				没有符合条件的记录
			</td>
		<tr>
    </tbody>  
	{/foreach}
</table>  
<!-- end wxtables -->  
<div class="tables-btmctrl clearfix">  
    <div class="fl">  
        <a href="javascript:;" class="btn btn-blue" onclick="Select()">全选</a>  
        <a href="javascript:;" class="btn btn-blue" onclick="Cancel()">取消</a>  
        <a href="javascript:;" onclick="batch_delete()" class="btn btn-blue">删除</a>
    </div>  
    <div class="fr">  
        <div class="paginate">
			{$page_str} 
        </div>  
        <!-- end paginate -->  
    </div>  
</div>  
<!-- end tables-btmctrl -->  
</div>  
<!-- end tablesWrap -->   
{/block} 

{block name="js"}
<script src="/Public/Plugins/My97DatePicker/WdatePicker.js?version={$version}"></script>
<script src="__JS__/clipboard.min.js"></script>
{literal}
<script>
	//全选
	function Select(){
		var sel=document.getElementsByName("a[]");
		for(var i=0;i<sel.length;i++){
			sel[i].checked=true;
		}
	}
	//取消全选
	function Cancel(){
		var sel=document.getElementsByName("a[]");
		for(var i=0;i<sel.length;i++){
			sel[i].checked=false;
		}
	}

function delete_service_type(type_id)
{
	$.jPops.confirm(
	{  
		 title:"提示",  
		 content:"您确定要删除这条数据吗？",  
		 okBtnTxt:"确定",  
		 cancelBtnTxt:"取消",  
		 callback:function(r)
		 {  
			 if(r)
			 {
				 $.post('/AcpSiteType/delete_site_type', {"type_id":type_id}, function(data, textStatus)
				 {
					if (data == 'success')
					{
						alert('恭喜您，删除成功！');
						location.reload();
					}
					else
					{
						alert('对不起，场地类型下存在场地，删除失败！');
					}
				});
			 }  
			 return true;  
		 }
	 });  	
}

function batch_delete()
{
	$.jPops.confirm(
	{  
		 title:"提示",  
		 content:"您确定要删除这些数据吗？",  
		 okBtnTxt:"确定",  
		 cancelBtnTxt:"取消",  
		 callback:function(r)
		 {  
			 if(r)
			 {
				 var type_ids = '';
				 var count = 0;
				 $('input[name="a[]"]:checked').each(function(){
					 count ++;
                     type_ids += $(this).val() + ',';
				 });

				 if (!count)
				 {
					 alert('对不起，请选择至少一项进行删除！');
					 return;
				 }

                 type_ids = type_ids.substr(0, type_ids.length - 1);

				 $.post('/AcpSiteType/batch_delete_site_type', {"type_ids":type_ids}, function(data, textStatus)
				 {
					if (data == 'success')
					{
						alert('恭喜您，删除成功！');
						location.reload();
					}
					else
					{
						alert('对不起，场地类型下存在场地，删除失败！');
					}
				});
			 }  
			 return true;  
		 }
	 });
}
//复制商品链接
function class_link(class_id)
{
    var link = 'http://' + document.domain + '/FrontMall/item_list/class_id/' + class_id;
    $.jPops.custom({
        title:"请复制链接",  
        content:'<div>一级分类链接：' + link + '</div>',
        okBtnTxt:"复制",  
        cancelBtnTxt:"关闭",  
        callback:function(r)
        {
            if(r)
            {
                text = link;
                copy_text('jpops-btn-ok');
            }
            else
            {
                return true;  
            }
        }
    });
}
function copy_text(id)
    {
        var clipboard = new Clipboard('#' + id, {
            text: function() {
                return text;
            }
        });

        clipboard.on('success', function(e) {
            console.log(e);
            alert('复制成功');
        });

        clipboard.on('error', function(e) {
            console.log(e);
            alert('复制失败，请手动复制');
        });
    }
</script>
{/literal}
{/block} 

{block name="css"}
<link type="text/css" rel="stylesheet" href="__ACPCSS__/tip.css" />
{literal}
<style>
.PageNext{page-break-after: always; height:1px;}
</style>
{/literal}
{/block} 
